package cn.tedu.javaadminly.demo.controller;


import cn.tedu.javaadminly.base.response.JsonResult;
import cn.tedu.javaadminly.demo.entity.Article;
import cn.tedu.javaadminly.demo.param.ArticleQueryParam;
import cn.tedu.javaadminly.demo.service.ArticleService;
import cn.tedu.javaadminly.demo.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/v1/article")
@Slf4j
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    @GetMapping("/search")
    public JsonResult searchArticles(ArticleQueryParam param) {
        log.debug("查询文章:param={}");
        List<Article> articles = articleService.searchArticles(param);
        return JsonResult.ok(articles);
    }
}